package io.renren.controller;

import java.util.List;
import java.util.Map;

import io.renren.entity.VO.SocialSecurityAreaBasicUpdateEntityVO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.SocialSecurityAreaBasicUpdateEntity;
import io.renren.service.SocialSecurityAreaBasicUpdateService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2017-07-08 17:23:31
 */
@RestController
@RequestMapping("socialsecurityareabasicupdate")
public class SocialSecurityAreaBasicUpdateController {
	@Autowired
	private SocialSecurityAreaBasicUpdateService socialSecurityAreaBasicUpdateService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("socialsecurityareabasicupdate:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<SocialSecurityAreaBasicUpdateEntityVO> socialSecurityAreaBasicUpdateList = socialSecurityAreaBasicUpdateService.queryList(query);
		int total = socialSecurityAreaBasicUpdateService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(socialSecurityAreaBasicUpdateList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("socialsecurityareabasicupdate:info")
	public R info(@PathVariable("id") Integer id){
		SocialSecurityAreaBasicUpdateEntity socialSecurityAreaBasicUpdate = socialSecurityAreaBasicUpdateService.queryObject(id);
		
		return R.ok().put("socialSecurityAreaBasicUpdate", socialSecurityAreaBasicUpdate);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("socialsecurityareabasicupdate:save")
	public R save(@RequestBody SocialSecurityAreaBasicUpdateEntity socialSecurityAreaBasicUpdate){
		socialSecurityAreaBasicUpdateService.save(socialSecurityAreaBasicUpdate);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("socialsecurityareabasicupdate:update")
	public R update(@RequestBody SocialSecurityAreaBasicUpdateEntity socialSecurityAreaBasicUpdate){
		socialSecurityAreaBasicUpdateService.update(socialSecurityAreaBasicUpdate);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("socialsecurityareabasicupdate:delete")
	public R delete(@RequestBody Integer[] ids){
		socialSecurityAreaBasicUpdateService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
